package com.gyms.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.classic.okhttp.beans.HVCitiesBean;
import com.classic.okhttp.beans.HVProductInfoBean;
import com.classic.okhttp.beans.HVProjectBean;
import com.classic.okhttp.beans.HVSubCitiesBean;
import com.classic.okhttp.beans.HVVenueBean;
import com.classic.okhttp.enums.Enum;
import com.classic.okhttp.services.IProductService;
import com.classic.okhttp.services.IVenueService;
import com.classic.okhttp.zmoumall.http.ObjectCallback;
import com.gyms.MyApplication;
import com.gyms.R;
import com.gyms.TimePopuSlect;
import com.gyms.adapter.AllCourseRecyClerAdapter;
import com.gyms.adapter.GymsRecyclertAdapter;
import com.gyms.adapter.SelectAdapter;
import com.gyms.base.MyAutoLayoutActivity;
import com.gyms.bean.ThreeWheelBean;
import com.gyms.constant.Constants;
import com.gyms.manager.LocationManger;
import com.gyms.view.wheel.WheelDialog;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;
import click.OnRecyclerViewItemClick;
import myInterface.OnItemClickLitener;
import refresh.PtrClassicFrameLayout;
import refresh.PtrDefaultHandler;
import refresh.PtrFrameLayout;
import refresh.PtrHandler;
import utils.BarUtils;
import utils.ScreenUtils;
import utils.StringUtils;
import weight.CommonEmptyView;
import weight.head_foot_recyclerView.EndlessRecyclerOnScrollListener;
import weight.head_foot_recyclerView.HeaderAndFooterRecyclerViewAdapter;
import weight.head_foot_recyclerView.LoadingFooter;
import weight.head_foot_recyclerView.RecyclerViewStateUtils;

import static android.view.View.VISIBLE;

/**
 * 搜索结果list
 * ltx
 */

public class SearchResultActivity extends MyAutoLayoutActivity implements  CommonEmptyView.UpdateClick, AdapterView.OnItemClickListener, OnRecyclerViewItemClick, WheelDialog.OnClickSubmitListener {

    @BindView(R.id.refresh_search_layout)
    RecyclerView mXvSearchLayout;
    @BindView(R.id.search_empty)
    CommonEmptyView mSearchEmpty;//空页面


    private LocationManger mLocationManger;
    private boolean isGymSearch;//是否是场馆查询
    private String mKeyWord;//查询关键字
    //场馆搜索
    private List<HVVenueBean> mHVVenueBeans = new ArrayList<>();//搜索的场馆列表的Beans
    private GymsRecyclertAdapter mAllGymAdapter;//搜索的场馆列表的adapter

    //产品搜索
    private List<HVProductInfoBean> mHVProductInfoBeans = new ArrayList<>();//搜索的产品的Beans
    private AllCourseRecyClerAdapter mAllCourseAdapter;//搜索的产品列表的adapter

    //下拉刷新相关
    private boolean isFresh = true;//是否是上拉刷新 上拉刷新 clear数据源

    //设置状态栏
    @BindView(R.id.statu_bar)
    ImageView mStatusBar;
    //搜索头相关
    @BindView(R.id.search_et_input)
    TextView mSearchEtInput;

    private int mSearchType;//搜索类型 分为 关键字搜索和标签搜索
    private boolean isTagSearch;//是否是标签搜索

    private String mTagTitle;//标签

    @BindView(R.id.tv_select_divider)
    TextView mTvSelectDivider;//筛选框分割线
    @BindView(R.id.tv_search_map)
    ImageView mIvSearchMap;//跳转地图


   @BindView(R.id.tv_gyms_category)
    TextView mTvSport;//运动分类显示view
   @BindView(R.id.tv_gyms_area)
    TextView mTvArea;//地区分类显示view

    private PopupWindow mPwSelectLayout;//搜索运动分类 区域弹出框
    private PopupWindow mPwBookType;//搜索预定类型的popupWindow

    private RecyclerView mRvSlectSport;//运动列表
    private SelectAdapter mSpAdapter;//筛选运动项目的适配器

    //初始化运动项目跟地区的数据
    private List<HVProjectBean> hVProjectBean;//运动分类beans
    private HVCitiesBean citiesBean;//城市的bean
    private ArrayList<String> mProjectList=new ArrayList<>();
    private ArrayList<HVSubCitiesBean> mAreasList;
    private  ArrayList<String> mAreaStrLists = new ArrayList<>();//地区显示列表
    private ArrayList<String> mSelectDataStrs=new ArrayList<>();//筛选的数据源 可能显示地区可能显示 运动分类
    private int mSelectType;//筛选选择的类型
    private final static int SELECT_AREA=0;//选择地区
    private final static int SELECT_SPORT=1;//选择运动项目

    private int mAreaSelectPos=0;//地区分类选中地址
    private int mSportSelectPos=0;//运动分类选中地址

    private String mProjectId, mAreaCode;//项目id和区域id
    private String mProjectName;//项目名称
    private ClickView mClickView;//点击事件View

    //预定类型相关

    private TextView mTvBookAll;
    private TextView mTvBookGym;
    private TextView mTvBookProduct;
    @BindView(R.id.tv_select_type)
     TextView mTvSelectType;
    @BindView(R.id.search_iv_delete)
     ImageView mIvDelete;//搜索框删除功能
    @BindView(R.id.tv_type_divider)
     TextView mTvTypeDivider;//分割线
    @BindView(R.id.ll_select_type)
     LinearLayout mLlSelectTypeLayout;//类型选择

    private TimePopuSlect mTimePopuSlect;
    private Integer startTime,endTime;//开始时间结束时间

    private int  mCurBookType;//当前选择的预定类型
    private ThreeWheelBean mWheelBean;//选择的bean
    private String mDayStr;

    private boolean isNeedSelected;//需不需要过滤
    private int mLLTypeHight;//选择类型的高度
    private LinearLayoutManager layoutManager;

    private Enum.EnumVenueListType venueListType;//预定类型

    private final int S_SELECT_COLOR=R.color.c_0396EB;//选中颜色
    private final int S_COMMON_COLOR=R.color.c_333333;//默认颜色
    private final int S_TYPE_SPORT=0;//运动选框
    private final int S_TYPE_BOOK=1;//预定选框
    private final int S_TYPE_AREA=2;//地区选框

    private int mCurSportColor=S_COMMON_COLOR;//当前运动分类的颜色
    private int mCurSelectTypeColor=S_COMMON_COLOR;//当前选择预定类型的颜色
    private int mCurAreaColor=S_COMMON_COLOR;

    private boolean isCurShowSport;//当前是否显示运动分类选择框
    //悬浮相关
    @BindView(R.id.ll_float)
    LinearLayout mLlFloat;//悬浮layout
    @BindView(R.id.tv_is_no_have)
    TextView mTvIsNoHave;//悬浮的内容View
    private int mSuspensionHeight;//悬浮框的高度
    private int mCurrentPosition=0;//当前位置
    private int mTempPos=-1;//悬浮的位置

    //刷新跟加载更多
    @BindView(R.id.pf_search_result)
    PtrClassicFrameLayout mPfSearchResult;
    //刷新
    private boolean isCanLoadMore=true;

    private OnStickScrollListen mOnStickOnScrollListen;


    @Override
    protected int getLayoutResId() {
        return R.layout.activity_search_result;
    }

    @Override
    protected void initView() {
        BarUtils.setStatuBar(mContext, mStatusBar);//将状态栏设置大小
        mOnStickOnScrollListen=new OnStickScrollListen();
        createLoadingView(getResources().getString(R.string.str_loading), true);
        //获取上层传递的数据
        Bundle mBundle = getIntent().getExtras();
        //初始化定位管理
        mLocationManger = LocationManger.getInstance(getApplicationContext());
        mAreaCode=mLocationManger.getCityCode();
        mClickView=new ClickView();
        //初始化运动分类 跟地区
        doInitSelectPw();
        initAreaList();
        initProjectList();
        //初始化区域
        String curArea = "全部区域";
        mTvArea.setText(curArea);
        getAreaCode(curArea);
        if (null != mBundle) {
            getExtrasData(mBundle);
        }
    }

    /**
     * 初始化搜素的弹出框
     */

    private void doInitSelectPw() {
        if(null==mPwSelectLayout){
          View mContentView= View.inflate(getApplicationContext(),R.layout.ll_pop_select_layout,null);
          mPwSelectLayout=new PopupWindow(mContentView,LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,false);
            mPwSelectLayout.setOutsideTouchable(false);
            mPwSelectLayout.setBackgroundDrawable(new BitmapDrawable(getResources(), (Bitmap) null));
            //初始化view
            mRvSlectSport= (RecyclerView) mContentView.findViewById(R.id.rv_select_sport);
            View spaceView = mContentView.findViewById(R.id.view_space);
            spaceView.setOnClickListener(mClickView) ;

            initSelectAdapter();
        }
    }

    /**
     * 初始化运动分类的适配器
     */

    private void initSelectAdapter() {
        GridLayoutManager mSportManger=new GridLayoutManager(this,5);
        mSpAdapter=new SelectAdapter(getApplicationContext());
        //设置onItemClick事件
        mSpAdapter.setOnRecyclerViewItemClick(this);
        mRvSlectSport.setAdapter(mSpAdapter);
        mRvSlectSport.setLayoutManager(mSportManger);
        mSpAdapter.setSelectDataStrs(mSelectDataStrs);
        mSpAdapter.notifyDataSetChanged();

    }

    /**
     * 获取其他页面传递的数据
     * @param mBundle bundle
     * 初始化搜索文本
     */

    private void getExtrasData(Bundle mBundle) {
        isGymSearch = mBundle.getBoolean(Constants.KEY_IS_GYM_SEARCH, false);
        initAdapter();
        doInitProductSelect(mBundle);
        mTvSport.setText(mProjectName);//设置项目名称
        mSearchType=mBundle.getInt(Constants.KEY_SEARCH_TYPE);//搜索类型


        mWheelBean = (ThreeWheelBean) mBundle.getSerializable("wheelBean");
        mCurBookType=mBundle.getInt(Constants.BOOK_TYPE,-1);//当前的预定类型
        if (mWheelBean != null) {
            startTime = mWheelBean.getStartTimeInt();
            endTime = mWheelBean.getEndTimeLInt();
            mDayStr = getString(R.string.str_gym_select_type,mWheelBean.getDateStr().substring(0, 2),mWheelBean.getStartTimeStr(),mWheelBean.getEndTimeStr());
        }
        initTypePw();
        initTimeSlectPw();


        whatBookType();
        doShowTypeView();
        if (isTagSearch) {
            mTagTitle = mBundle.getString(Constants.KEY_SEARCH_KEYWORD,"");
            mKeyWord="";//由于将该页面设为singleTask 需将其他重新赋值
        } else {
            mKeyWord = mBundle.getString(Constants.KEY_SEARCH_KEYWORD,"");
            mTagTitle="";
        }
        if(StringUtils.isNull(mTagTitle)&&StringUtils.isNull(mKeyWord)){//没有关键字和标签就隐藏 叉号 再 设置文本标签
            mIvDelete.setVisibility(View.GONE);
            mSearchEtInput.setText(isGymSearch?"找场馆":"找课程");//颜色 6666
            mSearchEtInput.setTextColor(ContextCompat.getColor(mContext,R.color.c_999999));
        }else{//有就设置颜色黑色
            mSearchEtInput.setTextColor(ContextCompat.getColor(mContext,R.color.c_333333));
            mIvDelete.setVisibility(View.VISIBLE);
            mSearchEtInput.setText(isTagSearch?mTagTitle:mKeyWord);
        }
        reFreshSearch();//刷新数据
    }

    /**
     * 初始化产品搜索
     * @param mBundle mBundle
     */

    private void doInitProductSelect(Bundle mBundle) {
        if(isGymSearch){
            mIvSearchMap.setVisibility(VISIBLE);
            mLlSelectTypeLayout.setVisibility(VISIBLE);//产品 隐藏选择类型
            mTvTypeDivider.setVisibility(VISIBLE);

        }else{//产品
            mIvSearchMap.setVisibility(View.INVISIBLE);
            mLlSelectTypeLayout.setVisibility(View.GONE);//产品 隐藏选择类型
            mTvTypeDivider.setVisibility(View.GONE);
            mProjectName="全部";
            getProjectId(mProjectName);//获取项目ID
            venueListType= Enum.EnumVenueListType.Product;

        }
        //获取ProjectId和项目名称
        mProjectId = mBundle.getString(Constants.FLAG_INTENT_PROJECTID);
        mProjectName = mBundle.getString(Constants.FLAG_INTENT_PROJECTNAME);
        if(StringUtils.isNull(mProjectId)){
            mProjectName="全部";
            venueListType= Enum.EnumVenueListType.All;
            mTvSelectType.setText("全部");
        }else{//定位当前的运动项目
            for (int pos=0;pos<mProjectList.size();pos++){
                if(mProjectName.equals(mProjectList.get(pos))){
                    mSportSelectPos=pos;//选中的运动分类复制
                    break;
                }
            }

        }
    }

    /**
     * 初始化类型选择pw
     */

    private void initTypePw() {
        if(null==mPwBookType){
            View typeView = View.inflate(getApplicationContext(), R.layout.ll_select_book_layout, null);
            mPwBookType=new PopupWindow(typeView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT,false);
            View mTypeSpace= typeView.findViewById(R.id.view_book_type_space);
            LinearLayout llSelectType = (LinearLayout) typeView.findViewById(R.id.ll_type_layout);
            llSelectType.measure(0,0);
            mLLTypeHight= llSelectType.getMeasuredHeight();//获取选择类型的高度
            mTvBookAll= (TextView) typeView.findViewById(R.id.tv_book_all);
            mTvBookGym= (TextView) typeView.findViewById(R.id.tv_book_gym);
            mTvBookProduct= (TextView) typeView.findViewById(R.id.tv_book_product);
            mTypeSpace.setOnClickListener(mClickView);
            mTvBookAll.setTag(0);
            mTvBookAll.setOnClickListener(mClickView);//
            mTvBookProduct.setTag(2);
            mTvBookProduct.setOnClickListener(mClickView);
            mTvBookGym.setTag(1);
            mTvBookGym.setOnClickListener(mClickView);
        }

    }

    /**
     *初始化预定类型
     */

    private void whatBookType() {
        switch (mCurBookType){
            case 0:
                mTvSelectType.setText("全部");
                venueListType= Enum.EnumVenueListType.All;
                mTvBookAll.setTextColor(ContextCompat.getColor(mContext,R.color.c_0396EB));
                mTvBookGym.setTextColor(ContextCompat.getColor(mContext,R.color.c_333333));
                mTvBookProduct.setTextColor(ContextCompat.getColor(mContext,R.color.c_333333));
                break;
            case 1:
                mTvSelectType.setText(mDayStr);
                venueListType= Enum.EnumVenueListType.Field;
                mTvBookAll.setTextColor(ContextCompat.getColor(mContext,R.color.c_333333));
                mTvBookGym.setTextColor(ContextCompat.getColor(mContext,R.color.c_0396EB));
                mTvBookProduct.setTextColor(ContextCompat.getColor(mContext,R.color.c_333333));
                break;

            case 2:
                mTvSelectType.setText("课程");
                venueListType= Enum.EnumVenueListType.Product;
                mTvBookAll.setTextColor(ContextCompat.getColor(mContext,R.color.c_333333));
                mTvBookGym.setTextColor(ContextCompat.getColor(mContext,R.color.c_333333));
                mTvBookProduct.setTextColor(ContextCompat.getColor(mContext,R.color.c_0396EB));

                break;
            default:

                break;
        }

    }

    /**
     * 设置搜索关键字 和标签的样式
     */

    private void doShowTypeView() {
        if(Constants.TYPE_TAB==mSearchType){//标签搜索
            mSearchEtInput.setBackgroundResource(R.drawable.sp_buy_blue_test);
            isTagSearch=true;
        }else if(Constants.TYPE_KEYWORD==mSearchType){//关键字搜索
            mSearchEtInput.setBackgroundResource(R.drawable.sp_buy_white);
            isTagSearch=false;
        }
    }

    @Override
    protected void setTitleTheme() {
        ScreenUtils.translateStatusBar(this);
    }

    @Override
    protected void onDestroy() {
        mXvSearchLayout.removeOnScrollListener(mOnScrollListener);
        mXvSearchLayout.removeOnScrollListener(mOnStickOnScrollListen);
        super.onDestroy();
    }

    /**
     * 根据是否场地搜索来初始化适配器
     * 场馆搜索就new 场馆适配器
     * 产品搜索就new 产品适配器
     */

    private void initAdapter() {
        if(null==layoutManager){
            layoutManager = new LinearLayoutManager(mContext);
            layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
            mXvSearchLayout.setLayoutManager(layoutManager);
        }
        if (isGymSearch&&null==mAllGymAdapter) {//场地搜索并且 场地适配器为null 初始化适配器
            mAllGymAdapter = new GymsRecyclertAdapter(mContext,mHVVenueBeans);
            mAllGymAdapter.setOnItemClickLitener(new OnItemClickLitener() {
                @Override
                public void onItemClick(View view, int position) {
                    goGymDetail(position);
                }
            });
            HeaderAndFooterRecyclerViewAdapter headerAndFooterRecyclerViewAdapter = new HeaderAndFooterRecyclerViewAdapter(mAllGymAdapter);
            mXvSearchLayout.setAdapter(headerAndFooterRecyclerViewAdapter);
            mXvSearchLayout.addOnScrollListener(mOnScrollListener);
        } else if(!isGymSearch&&null==mAllCourseAdapter) {//产品搜索并且 产品适配器为null 初始化适配器
            mAllCourseAdapter = new AllCourseRecyClerAdapter(mContext, mHVProductInfoBeans);
            HeaderAndFooterRecyclerViewAdapter headerAndFooterRecyclerViewAdapter = new HeaderAndFooterRecyclerViewAdapter(mAllCourseAdapter);
            mXvSearchLayout.setAdapter(headerAndFooterRecyclerViewAdapter);
            mXvSearchLayout.addOnScrollListener(mOnScrollListener);
            mAllCourseAdapter.setOnItemClickLitener(new OnItemClickLitener() {
                @Override
                public void onItemClick(View view, int position) {
                    goProductDetail(position);
                }
            });
        }
    }

    @Override
    protected void setListener() {
        mSearchEmpty.setUpDateClick(this);
        mPfSearchResult.setPtrHandler(new PtrHandler() {
            @Override
            public void onRefreshBegin(PtrFrameLayout frame) {
                reFreshSearch();
            }

            @Override
            public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
                return PtrDefaultHandler.checkContentCanBePulledDown(frame, content, header);
            }
        });

      mPwBookType.setOnDismissListener(new PopupWindow.OnDismissListener() {
          @Override
          public void onDismiss() {
              mCurSelectTypeColor=S_COMMON_COLOR;
              doTvSetColor(mTvSelectType,mCurSelectTypeColor);

          }
      });

      mPwSelectLayout.setOnDismissListener(new PopupWindow.OnDismissListener() {
          @Override
          public void onDismiss() {
              if(isCurShowSport){//当前显示的是运动分类
                  mCurSportColor=S_COMMON_COLOR;
                  doTvSetColor(mTvSport,mCurSportColor);
              }else{
                  mCurAreaColor=S_COMMON_COLOR;
                  doTvSetColor(mTvArea,mCurAreaColor);
              }
          }
      });
      //recyclerView 悬浮相关

        mXvSearchLayout.addOnScrollListener(mOnStickOnScrollListen);

    }

    @Override
    protected void processLogic() {

    }

    /**
     * 获取场馆数据或者获取产品数据
     *
     */

    private void getData() {
        if (isGymSearch) {//获取场馆列表
            getVenueList();
        } else {//获取产品列表
            getProductList();
        }
    }

    /**
     * 根据搜索关键字获取内容
     *
     */
    private void getVenueList() {
        if(isFresh)
        loadingView.show();
        IVenueService.getVenueList(this, mAreaCode, mLocationManger.longitude, mLocationManger.latitude, mProjectId, startTime, endTime, mKeyWord, mPageIndex, PAGESIZE, venueListType, mTagTitle,null,false, new ObjectCallback<ArrayList<HVVenueBean>>() {
            @Override
            public void onHttpErrorCall(int statusCode) {
                dialogDis();
                RecyclerViewStateUtils.setFooterViewState(mXvSearchLayout, LoadingFooter.State.NetWorkError);
                if(isFresh){
                    showEmptyView(mXvSearchLayout, mSearchEmpty,Constants.NO_NET);
                }else{
                    mPageIndex--;
                    RecyclerViewStateUtils.setFooterViewState(SearchResultActivity.this, mXvSearchLayout, PAGESIZE, LoadingFooter.State.NetWorkError, mFooterClick);
                }
            }

            @Override
            public void onSuccess(ArrayList<HVVenueBean> response, String message) {
                dialogDis();
                if (isFresh) {//刷新的时候 清空数据源
                    mPfSearchResult.refreshComplete();
                    mHVVenueBeans.clear();
                    isNeedSelected=true;
                } else {
                    RecyclerViewStateUtils.setFooterViewState(mXvSearchLayout, LoadingFooter.State.Normal);
                }
                if (null != response && response.size() != 0) {
                    dismissEmptyView(mXvSearchLayout, mSearchEmpty);//空页面隐藏
                    mHVVenueBeans.addAll(response);
                    if(isNeedSelected){
                        doSelectBeans();
                    }
                    mAllGymAdapter.notifyDataSetChanged();
                    if(isFresh){//刷新的时候数据滚到第一条
                        mXvSearchLayout.smoothScrollToPosition(0);
                    }
                } else {//找不到合适的场地
                    if (isFresh) {
                        showEmptyView(mXvSearchLayout, mSearchEmpty, 1);//空页面出现
                        mXvSearchLayout.setVisibility(View.GONE);
                        mAllGymAdapter.notifyDataSetChanged();
                    } else {
                        mPageIndex--;
                        RecyclerViewStateUtils.setFooterViewState(mXvSearchLayout, LoadingFooter.State.TheEnd);
                        isCanLoadMore=false;
                    }
                }
            }

            @Override
            public void onErrorT(int code, ArrayList<HVVenueBean> response, String errorMessage) {
                dialogDis();
               /* showEmptyView(mXvSearchLayout, mSearchEmpty, code);//无网络的状态*/
               if(isFresh){
                   showEmptyView(mXvSearchLayout, mSearchEmpty, code);
               }else{
                   mPageIndex--;
                   RecyclerViewStateUtils.setFooterViewState(SearchResultActivity.this, mXvSearchLayout, PAGESIZE, LoadingFooter.State.NetWorkError, mFooterClick);
               }
            }
        });
    }

    /**
     * 筛选是否符合条件
     */

    private void doSelectBeans() {
        int mCount=mHVVenueBeans.size();
        int tempPos=-1;//没有符合的临界pos
        for(int pos=0;pos<mCount;pos++){
            HVVenueBean mGymBean=mHVVenueBeans.get(pos);
            if(!mGymBean.getMatchCondition()){
                HVVenueBean mGymBeanNew=new HVVenueBean();
                mGymBeanNew.isCanAdd=true;
                mHVVenueBeans.add(pos,mGymBeanNew);
                isNeedSelected=false;
                tempPos=pos;
                break;
            }
        }
        if(tempPos==0){//没有找到符合的
            mTvIsNoHave.setText(getResources().getText(R.string.str_no_have));
        }else{//没有找到满意的
            mTvIsNoHave.setText(getResources().getText(R.string.str_no_happy));
        }
    }


    /**
     * 根据搜索关键字获取内容
     *
     */
    private void getProductList() {
        if(isFresh)
        loadingView.show();
        IProductService.getProductList(this, mAreaCode, mLocationManger.longitude, mLocationManger.latitude, mKeyWord, mPageIndex, PAGESIZE, mProjectId, mTagTitle,false, new ObjectCallback<ArrayList<HVProductInfoBean>>() {
            @Override
            public void onHttpErrorCall(int statusCode) {
                dialogDis();
                RecyclerViewStateUtils.setFooterViewState(mXvSearchLayout, LoadingFooter.State.NetWorkError);
                if(isFresh){
                    showEmptyView(mXvSearchLayout, mSearchEmpty,Constants.NO_NET);
                }else{
                    mPageIndex--;
                    RecyclerViewStateUtils.setFooterViewState(SearchResultActivity.this, mXvSearchLayout, PAGESIZE, LoadingFooter.State.NetWorkError, mFooterClick);
                }
            }

            @Override
            public void onSuccess(ArrayList<HVProductInfoBean> response, String message) {
                dialogDis();
                if (isFresh) {
                    mXvSearchLayout.smoothScrollToPosition(0);
                    mPfSearchResult.refreshComplete();
                    mHVProductInfoBeans.clear();
                } else {
                    RecyclerViewStateUtils.setFooterViewState(mXvSearchLayout, LoadingFooter.State.Normal);
                }
                if (null != response && response.size() != 0) {
                    mXvSearchLayout.setVisibility(VISIBLE);//展示结果列表显示
                    dismissEmptyView(mXvSearchLayout, mSearchEmpty);//空页面隐藏
                    mHVProductInfoBeans.addAll(response);
                    mAllCourseAdapter.notifyDataSetChanged();
                } else {//找不到合适的场地
                    if (isFresh) {
                        showEmptyView(mXvSearchLayout, mSearchEmpty, 1);//空页面出现
                        mXvSearchLayout.setVisibility(View.GONE);
                        mAllCourseAdapter.notifyDataSetChanged();
                    } else {
                        mPageIndex--;
                        RecyclerViewStateUtils.setFooterViewState(mXvSearchLayout, LoadingFooter.State.TheEnd);
                        isCanLoadMore=false;
                    }
                }
            }

            @Override
            public void onErrorT(int code, ArrayList<HVProductInfoBean> response, String errorMessage) {
                dialogDis();
                RecyclerViewStateUtils.setFooterViewState(mXvSearchLayout, LoadingFooter.State.NetWorkError);
                if(isFresh){
                    showEmptyView(mXvSearchLayout, mSearchEmpty,Constants.NO_NET);
                }else{
                    mPageIndex--;
                    RecyclerViewStateUtils.setFooterViewState(SearchResultActivity.this, mXvSearchLayout, PAGESIZE, LoadingFooter.State.NetWorkError, mFooterClick);
                }
            }
        });
    }

    /**
     * 刷新列表
     */

    private void reFreshSearch() {
        isCanLoadMore=true;
        //刷新的时候将pageIndex始终为1
        mTempPos=-1;
        mCurrentPosition=0;//悬浮的初始化
        mLlFloat.setVisibility(View.GONE);

        isFresh = true;
        mPageIndex = 1;
        mIsRefreshOrLoadMore = 0;
        getData();
    }

    /**
     * 加载更多
     */

    private void doLoadMore() {
        isFresh = false;
        mPageIndex++;
        mIsRefreshOrLoadMore = 1;
        getData();
    }

    @Override
    public void onUpdateClick() {
        reFreshSearch();
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        if (isGymSearch) {
            goGymDetail(position);
        } else {
            goProductDetail(position);
        }
    }

    /**
     * 跳转产品详情
     *
     * @param position pos
     */
    private void goProductDetail(int position) {
        if (StringUtils.isNull(mHVProductInfoBeans)) {
            return;
        }
        Bundle mBundle = new Bundle();
        HVProductInfoBean mProductBean = mHVProductInfoBeans.get(position);
        mBundle.putString(Constants.FALG_INTENT_PRPDUCT_ID, mProductBean.getProductId());
        startActivity(ProductDetailsActivity.class, mBundle, false);
    }

    /**
     * 跳转 场馆详情
     *
     * @param position pos
     */
    private void goGymDetail(int position) {
        if (StringUtils.isNull(mHVVenueBeans)) {
            return;
        }
        Bundle mBundle = new Bundle();
        HVVenueBean mHVVenueBean = mHVVenueBeans.get(position);
        mBundle.putString(Constants.FLAG_INTENT_VENUEID, mHVVenueBean.getVenueId());
        startActivity(GymDetailActivity.class, mBundle, false);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        hideKeyBoard(ev);//隐藏软键盘
        return super.dispatchTouchEvent(ev);
    }

    @OnClick({R.id.fl_result_head,R.id.ll_select_area,R.id.ll_select_sport,R.id.ll_select_type,R.id.tv_search_map,R.id.search_btn_back,R.id.search_iv_delete,R.id.ll_float})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.fl_result_head://搜索点击 回搜索页面
                Intent mIntent=new Intent(this,SearchActivity.class);
                mIntent.putExtra(Constants.KEY_IS_GYM_SEARCH,isGymSearch);//是否是场馆搜索
                mIntent.putExtra(Constants.KEY_SEARCH_KEYWORD,isTagSearch?mTagTitle:mKeyWord);//搜索关键字
                mIntent.putExtra(Constants.FLAG_INTENT_PROJECTID, mProjectId);//id
                mIntent.putExtra(Constants.FLAG_INTENT_PROJECTNAME, mProjectName);//name
                mIntent.putExtra(Constants.BOOK_TYPE,mCurBookType);
                mIntent.putExtra(Constants.WHEELBEAN_TALG,mWheelBean);
                startActivity(mIntent);
                ((Activity) mContext).overridePendingTransition(0, 0);//去除默认系统动画
                break;
            case R.id.tv_search_map://地图页面
                Bundle mBundle=new Bundle();
                mBundle.putBoolean(Constants.IS_MAP_FROM_SEARCH,true);//从搜索结果进去 map 展示 场馆分布
                mBundle.putString(Constants.FLAG_INTENT_PROJECTID,mProjectId);
                if(null!=mLocationManger.latitude&&null!=mLocationManger.longitude){
                    mBundle.putDouble(Constants.FLAG_INTENT_LATITUDE,mLocationManger.latitude);
                    mBundle.putDouble(Constants.FLAG_INTENT_LONGITUDE,mLocationManger.longitude);
                }
                startActivity(LocationMapActivity.class,mBundle,false);
                break;

            case R.id.ll_select_area://选择地区筛选
                mCurAreaColor= doShowPwStatues(S_TYPE_AREA,mCurAreaColor);

                if(mCurAreaColor==S_SELECT_COLOR){//返回的是选中的颜色
                    doShowSelectPopup(mAreaStrLists,SELECT_AREA);//弹起
                }else{//返回的是普通的颜色
                    mPwSelectLayout.dismiss();
                }
              break;

            case R.id.ll_select_sport://选择运动分类

                mCurSportColor= doShowPwStatues(S_TYPE_SPORT,mCurSportColor);


                if(mCurSportColor==S_SELECT_COLOR){//返回的是选中的颜色
                    doShowSelectPopup(mProjectList,SELECT_SPORT);//弹起
                }else{//返回的是普通的颜色
                    mPwSelectLayout.dismiss();
                }

                break;
            case R.id.ll_select_type://预定类型
                mCurSelectTypeColor= doShowPwStatues(S_TYPE_BOOK,mCurSelectTypeColor);

                if(mCurSelectTypeColor==S_SELECT_COLOR){//返回的是选中的颜色
                    initTypeSelectPop();//弹起
                }else{//返回的是普通的颜色
                    if(null!=mTimePopuSlect){
                        mTimePopuSlect.dismiss();
                    }
                    if(null!=mPwBookType){
                        mPwBookType.dismiss();
                    }
                }


                break;

            case R.id.search_btn_back:
                finish();
                break;
            case R.id.search_iv_delete://删除关键字或者标签
                mIvDelete.setVisibility(View.GONE);
                mSearchEtInput.setBackgroundResource(R.drawable.sp_buy_white);
                if(isTagSearch){//如果标签搜索 标签滞空
                    mTagTitle="";
                }else{
                    mKeyWord="";
                }
                mSearchEtInput.setText(isGymSearch?"找场馆":"找课程");//颜色 6666
                mSearchEtInput.setTextColor(ContextCompat.getColor(mContext,R.color.c_999999));
                reFreshSearch();
                break;

            case R.id.ll_float:

                break;
        }
    }
    /**
     * 搜索框的点击效果  当前的文案变为蓝色  当前的已经弹起就回收 反之就弹起
     * 返回当前的颜色值
     * @param CurPw 当前的Pw类型
     *  @param mCurTextCor 当前的文案颜色
     */
    private int doShowPwStatues(int CurPw,int mCurTextCor){
        int mCurColor=-1;
        int mElseColor;
        switch (CurPw){
            case S_TYPE_SPORT://运动分类
                if(mCurTextCor==S_COMMON_COLOR){//点击的时候当前的颜色是默认的 就将它设置成选中的颜色 其他设置为默认
                    mCurColor=S_SELECT_COLOR;
                    mElseColor=S_COMMON_COLOR;

                    doTvSetColor(mTvSelectType,mElseColor);
                    doTvSetColor(mTvArea,mElseColor);
                }else{//如果点击时当前为选中的颜色 自己设为正常的颜色
                    mCurColor=S_COMMON_COLOR;
                }
                doTvSetColor(mTvSport,mCurColor);


                break;
            case S_TYPE_BOOK://预定

                if(mCurTextCor==S_COMMON_COLOR){//点击的时候当前的颜色是默认的 就将它设置成选中的颜色 其他设置为默认
                    mCurColor=S_SELECT_COLOR;
                    mElseColor=S_COMMON_COLOR;

                    doTvSetColor(mTvSport,mElseColor);
                    doTvSetColor(mTvArea,mElseColor);
                }else{//如果点击时当前为选中的颜色 自己设为正常的颜色
                    mCurColor=S_COMMON_COLOR;
                }
                doTvSetColor(mTvSelectType,mCurColor);

                break;

            case S_TYPE_AREA://地区选择
                if(mCurTextCor==S_COMMON_COLOR){//点击的时候当前的颜色是默认的 就将它设置成选中的颜色 其他设置为默认
                    mCurColor=S_SELECT_COLOR;
                    mElseColor=S_COMMON_COLOR;

                    doTvSetColor(mTvSport,mElseColor);
                    doTvSetColor(mTvSelectType,mElseColor);
                }else{//如果点击时当前为选中的颜色 自己设为正常的颜色
                    mCurColor=S_COMMON_COLOR;
                }
                doTvSetColor(mTvArea,mCurColor);

                break;
            default:

                break;
        }

        return mCurColor;

    }

    /**
     * 设置字体颜色
     * @param mTv view
     * @param mColor 颜色
     */

    private void doTvSetColor(TextView mTv,int mColor){
        mTv.setTextColor(ContextCompat.getColor(mContext,mColor));
    }

    /**
     * 初始化类型选择的弹出框
     */

    private void initTypeSelectPop() {
        mPwSelectLayout.dismiss();
       /* if (android.os.Build.VERSION.SDK_INT >=24) {
            int[] a = new int[2];
            mTvSelectDivider.getLocationInWindow(a);
            mPwBookType.showAtLocation(getWindow().getDecorView(), Gravity.NO_GRAVITY, 0 , a[1]+mTvSelectDivider.getHeight());
        } else{
            mPwBookType.showAsDropDown(mTvSelectDivider);
        }*/
        if (android.os.Build.VERSION.SDK_INT >=24) {
            int[] location = new int[2];
            mTvSelectDivider.getLocationOnScreen(location);
            // 7.1 版本处理
            if (Build.VERSION.SDK_INT >= 25) {//兼容7.1
                //【note!】Gets the screen height without the virtual key
                WindowManager wm = (WindowManager) mPwBookType.getContentView().getContext().getSystemService(Context.WINDOW_SERVICE);
                int screenHeight = wm.getDefaultDisplay().getHeight();
                /*
                /*
                 * PopupWindow height for match_parent,
                 * will occupy the entire screen, it needs to do special treatment in Android 7.1
                */
                mPwBookType.setHeight(screenHeight - location[1] - mTvSelectDivider.getHeight());
            }
            mPwBookType.showAtLocation(mTvSelectDivider, Gravity.NO_GRAVITY, 0, location[1] + mTvSelectDivider.getHeight());
        } else {
            mPwBookType.showAsDropDown(mTvSelectDivider);
        }

        if(mCurBookType==1){//上次选择预定
            mTimePopuSlect.showAsDropDown(mTvSelectDivider,0,mLLTypeHight);
        }
    }

    /**
     * 弹出选择预定类型的pop
     * @param mDataStrs 运动分类跟区域数据源
     * @param selectSport 当前选择的位置
     */

    private void doShowSelectPopup(ArrayList<String> mDataStrs, int selectSport) {
        mSelectDataStrs.clear();
        if(null!=mTimePopuSlect){
            mTimePopuSlect.dismiss();
        }
        if(null!=mPwBookType){
            mPwBookType.dismiss();
        }


        mSelectType=selectSport;//设置当前选择的类型
        mSelectDataStrs.addAll(mDataStrs);
        mSpAdapter.setSelectPos(selectSport==SELECT_AREA?mAreaSelectPos:mSportSelectPos);
        mSpAdapter.notifyDataSetChanged();
        mPwSelectLayout.dismiss();
        isCurShowSport = SELECT_SPORT == selectSport;
        /*if (android.os.Build.VERSION.SDK_INT >=24) {
            int[] a = new int[2];
            mTvSelectDivider.getLocationInWindow(a);
            mPwSelectLayout.showAtLocation(getWindow().getDecorView(), Gravity.NO_GRAVITY, 0 , a[1]+mTvSelectDivider.getHeight());
        } else{
            mPwSelectLayout.showAsDropDown(mTvSelectDivider);//在分割线下显示
        }*/
        if (android.os.Build.VERSION.SDK_INT >=24) {
            int[] location = new int[2];
            mTvSelectDivider.getLocationOnScreen(location);
            // 7.1 版本处理
            if (Build.VERSION.SDK_INT >= 25) {//兼容7.1
                //【note!】Gets the screen height without the virtual key
                WindowManager wm = (WindowManager) mPwSelectLayout.getContentView().getContext().getSystemService(Context.WINDOW_SERVICE);
                int screenHeight = wm.getDefaultDisplay().getHeight();
                /*
                /*
                 * PopupWindow height for match_parent,
                 * will occupy the entire screen, it needs to do special treatment in Android 7.1
                */
                mPwSelectLayout.setHeight(screenHeight - location[1] - mTvSelectDivider.getHeight());
            }
            mPwSelectLayout.showAtLocation(mTvSelectDivider, Gravity.NO_GRAVITY, 0, location[1] + mTvSelectDivider.getHeight());
        } else {
            mPwSelectLayout.showAsDropDown(mTvSelectDivider);
        }
    }


    /**
     * 已经存在这个实例不会再创建这个实例 调用其的onNewIntent
     * @param intent intent
     */

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        Bundle mBundle=intent.getExtras();
        if (null != mBundle) {
            getExtrasData(mBundle);
        }
    }

    /**
     * 初始化运动分类列表
     */

    private void initProjectList() {
        hVProjectBean = ((MyApplication) getApplication()).mHVProjectBean;
        mProjectList.add(Constants.ALL_SPORT_STR);//添加默认的全部
        if (hVProjectBean == null) {
            return;
        }
        for (HVProjectBean bean : hVProjectBean) {
            mProjectList.add(bean.getProjectName());
        }
    }
    /**
     * 初始化地区列表
     */

    private void initAreaList() {
        citiesBean = mLocationManger.getCurHVCitiesBean();
        if (citiesBean != null) {
            mAreasList = citiesBean.getAreas();
        }

        mAreaStrLists.add(Constants.ALL_AREAS);//添加全部区域
        if (mAreasList == null) {
            return;
        }
        for (HVSubCitiesBean area : mAreasList) {
            mAreaStrLists.add(area.getName());
        }
    }
    /**
     * 根据projectName获取ProjectId 将全部运动显示 所有运动
     * @param mTempProjectName 运动名称
     */

    private void getProjectId(String mTempProjectName) {
        if (mTempProjectName.equals(Constants.ALL_SPORT_STR)){//全部
            mProjectId=null;
            mProjectName=Constants.ALL_SPORT_STR;
        }else {
            mProjectName=mTempProjectName;
            //非全部去查询ProjectId
            for (HVProjectBean bean : hVProjectBean) {
                if (mProjectName.equals(bean.getProjectName())) {
                    mProjectId = bean.getProjectId();
                    break;
                }
            }
        }

    }

    /**
     * 根据地区名称查询AreaCode
     * @param mTempAreaStr 地区名称
     */

    private void getAreaCode(String mTempAreaStr) {
        if ("全部区域".equals(mTempAreaStr)&&null!=citiesBean) {
            mAreaCode = citiesBean.getAreaid();
        } else {
            if (mAreasList == null) {
                return;
            }
            for (HVSubCitiesBean area : mAreasList) {
                if (mTempAreaStr.equals(area.getName())) {
                    mAreaCode = area.getAreaid();
                    break;
                }
            }
        }
    }

    @Override
    public void onClickSubmit(String[] values, ThreeWheelBean threeWheelBean) {
        String mStrSelectType= getString(R.string.str_gym_select_type,threeWheelBean.getDateStr().substring(0, 2),threeWheelBean.getStartTimeStr(),threeWheelBean.getEndTimeStr());
        mTvSelectType.setText(mStrSelectType);
         startTime = threeWheelBean.getStartTimeInt();
         endTime = threeWheelBean.getEndTimeLInt();
         mWheelBean=threeWheelBean;
         mPwBookType.dismiss();
         reFreshSearch();
    }

    @Override
    public void onNotTimeSelect() {//不按时间筛选
        mPwBookType.dismiss();
        mTvSelectType.setText(R.string.str_book_no_time);
        startTime=null;//不限时间 开始结束时间为null
        endTime=null;
        venueListType= Enum.EnumVenueListType.Field;
        reFreshSearch();

    }

    @Override
    public void onRecyclerItemClick(RecyclerView view, int pos) {
        switch (mSelectType){
            case SELECT_AREA://点击地区分类
                String mSingleArea=mAreaStrLists.get(pos);
                getAreaCode(mSingleArea);//获取地区编号
                mTvArea.setText(mSingleArea);
                mPwSelectLayout.dismiss();
                mAreaSelectPos=pos;
                mSpAdapter.setSelectPos(pos);//设置选中的颜色
                reFreshSearch();
                break;
            case  SELECT_SPORT:// 点击运动分类
                String mSingleSport=mProjectList.get(pos);
                getProjectId(mSingleSport);//获取项目id
                mTvSport.setText(mSingleSport);
                mPwSelectLayout.dismiss();
                mSportSelectPos=pos;
                mSpAdapter.setSelectPos(pos);//设置选中的颜色
                reFreshSearch();
                break;

            default:

                break;
        }

    }

    private class ClickView implements View.OnClickListener{

        @Override
        public void onClick(View v) {

            switch (v.getId()){
                case R.id.view_space://类型筛选空白点击
                    mPwSelectLayout.dismiss();
                    if(null!=mTimePopuSlect){
                        mTimePopuSlect.dismiss();
                    }
                    break;
                case R.id.view_book_type_space:
                    mPwBookType.dismiss();
                    if(null!=mTimePopuSlect){
                        mTimePopuSlect.dismiss();
                    }
                    break;
                case R.id.tv_book_all://预定全部

                case R.id.tv_book_gym://预定场馆

                 case R.id.tv_book_product://课程
                     int mSelctPos= (int) v.getTag();
                     doSelectColor(mSelctPos);
                     mCurBookType=mSelctPos;//记住当前选择的预定类型

                    break;

                 default:
                     break;
            }
        }
    }

    /**
     * 设置不一样的选择效果
     * @param mSelctPos 当前选择的pos
     */

    private void doSelectColor(int mSelctPos) {


        switch (mSelctPos){
            case 0://全部
                mTvBookAll.setTextColor(ContextCompat.getColor(mContext,R.color.c_0396EB));
                mTvBookGym.setTextColor(ContextCompat.getColor(mContext,R.color.c_333333));
                mTvBookProduct.setTextColor(ContextCompat.getColor(mContext,R.color.c_333333));
                mTvSelectType.setText("全部");
                mPwBookType.dismiss();
                venueListType= Enum.EnumVenueListType.All;
                reFreshSearch();

                if(null!=mTimePopuSlect){
                    mTimePopuSlect.dismiss();

                }

                break;
            case 1://预定
                mTvBookAll.setTextColor(ContextCompat.getColor(mContext,R.color.c_333333));
                mTvBookGym.setTextColor(ContextCompat.getColor(mContext,R.color.c_0396EB));
                mTvBookProduct.setTextColor(ContextCompat.getColor(mContext,R.color.c_333333));
                mTimePopuSlect.showAsDropDown(mTvSelectDivider,0,mLLTypeHight);
                venueListType= Enum.EnumVenueListType.Field;
//                reFreshSearch();

                break;
            case 2://课程
                mTvBookAll.setTextColor(ContextCompat.getColor(mContext,R.color.c_333333));
                mTvBookGym.setTextColor(ContextCompat.getColor(mContext,R.color.c_333333));
                mTvBookProduct.setTextColor(ContextCompat.getColor(mContext,R.color.c_0396EB));
                mTvSelectType.setText("课程");
                venueListType= Enum.EnumVenueListType.Product;
                reFreshSearch();
                mPwBookType.dismiss();
                if(null!=mTimePopuSlect){
                    mTimePopuSlect.dismiss();

                }

                break;
            default:

                break;

        }

    }

    /**
     * 初始化时间选择的Pw
     */

    private void initTimeSlectPw() {
        if(null==mTimePopuSlect){
            mTimePopuSlect=new TimePopuSlect(this);
            mTimePopuSlect.setOnClickSubmitListener(this);
            mTimePopuSlect.setDate();
        }
    }

    /**
     * 上拉加载监听
     */

    private EndlessRecyclerOnScrollListener mOnScrollListener = new EndlessRecyclerOnScrollListener() {

        @Override
        public void onLoadNextPage(View view) {
            super.onLoadNextPage(view);
            if(StringUtils.isNull(mXvSearchLayout)){
                return;
            }
            LoadingFooter.State state = RecyclerViewStateUtils.getFooterViewState(mXvSearchLayout);
            if(state == LoadingFooter.State.Loading) {
                return;
            }

            if (isCanLoadMore) {
                // loading more
                RecyclerViewStateUtils.setFooterViewState(SearchResultActivity.this, mXvSearchLayout, PAGESIZE, LoadingFooter.State.Loading, null);
                doLoadMore();
            } else {
                //the end
                RecyclerViewStateUtils.setFooterViewState(SearchResultActivity.this, mXvSearchLayout, PAGESIZE, LoadingFooter.State.TheEnd, null);
            }
        }
    };

    /**
     * 悬浮监听器
     */

    private class OnStickScrollListen extends RecyclerView.OnScrollListener {
        @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
            if(StringUtils.isNull(mLlFloat)){
                return;
            }
            mSuspensionHeight = mLlFloat.getHeight();
        }

        @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            if(StringUtils.isNull(mHVVenueBeans)){
                return;
            }
            if (mAllGymAdapter.getItemViewType(mCurrentPosition) == GymsRecyclertAdapter.TYPE_TITLE) {//获取当前的类型 是否是空布局
                View view = layoutManager.findViewByPosition(mCurrentPosition);//拿到空布局
                mTempPos=mCurrentPosition + 1;
                if (view != null) {
                    if (view.getTop() < mSuspensionHeight) {
                        mLlFloat.setY(-(mSuspensionHeight - view.getTop()));
                    } else if(view.getTop()==0){
                        mLlFloat.setVisibility(View.VISIBLE);
                        mLlFloat.setY(0);
                    }else {
                        mLlFloat.setY(0);
                    }
                }
            }

            if (mCurrentPosition != layoutManager.findFirstVisibleItemPosition()) {
                mCurrentPosition = layoutManager.findFirstVisibleItemPosition();
            }
            if(mCurrentPosition>=mTempPos-1&&mTempPos!=-1&&layoutManager.findFirstCompletelyVisibleItemPosition()!=0){//当前为没有数据的就隐藏
                mCurrentPosition = layoutManager.findFirstVisibleItemPosition();
                mLlFloat.setY(0);
                mLlFloat.setVisibility(View.VISIBLE);
            }else{
                mLlFloat.setVisibility(View.GONE);
            }

        }
    }

    private View.OnClickListener mFooterClick = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            RecyclerViewStateUtils.setFooterViewState(SearchResultActivity.this, mXvSearchLayout, PAGESIZE, LoadingFooter.State.Loading, null);
            doLoadMore();
        }
    };
}
